package com.chenjt.netty.ten_zerocopy;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 传统IO读取
 * 客户端读取磁盘上的文件，将文件通过socket的outputStream发送到服务器端，记录发送完成的时间
 * 服务器端读取客户端发送过来的流式数据，当数据读取完成时断开读取操作
 *
 * @author chenjt
 * @date 2024/9/2 10:09
 */
public class OldServer {


    public static void main(String[] args) throws Exception {

        ServerSocket serverSocket = new ServerSocket(8899);

        while(true){
            Socket socket = serverSocket.accept();
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());

            try {
                byte[] byteArray = new byte[4096];

                while(true){
                    int readCount = dataInputStream.read(byteArray,0,byteArray.length);

                    if(-1 == readCount){
                        break;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

}
